package com.ruoyi.web.controller.approve;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ExaBorrowmoney;
import com.ruoyi.service.IExaBorrowmoneyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2020-07-02
 */
@Controller
@RequestMapping("/ruoyi/borrowmoney")
public class ExaBorrowmoneyController extends BaseController
{
    private String prefix = "ruoyi/borrowmoney";

    @Autowired
    private IExaBorrowmoneyService exaBorrowmoneyService;

    @RequiresPermissions("ruoyi:borrowmoney:view")
    @GetMapping()
    public String borrowmoney()
    {
        return prefix + "/borrowmoney";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:borrowmoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExaBorrowmoney exaBorrowmoney)
    {
        startPage();
        List<ExaBorrowmoney> list = exaBorrowmoneyService.selectExaBorrowmoneyList(exaBorrowmoney);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:borrowmoney:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExaBorrowmoney exaBorrowmoney)
    {
        List<ExaBorrowmoney> list = exaBorrowmoneyService.selectExaBorrowmoneyList(exaBorrowmoney);
        ExcelUtil<ExaBorrowmoney> util = new ExcelUtil<ExaBorrowmoney>(ExaBorrowmoney.class);
        return util.exportExcel(list, "borrowmoney");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:borrowmoney:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExaBorrowmoney exaBorrowmoney)
    {
        return toAjax(exaBorrowmoneyService.insertExaBorrowmoney(exaBorrowmoney));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{bId}")
    public String edit(@PathVariable("bId") Long bId, ModelMap mmap)
    {
        ExaBorrowmoney exaBorrowmoney = exaBorrowmoneyService.selectExaBorrowmoneyById(bId);
        mmap.put("exaBorrowmoney", exaBorrowmoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:borrowmoney:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExaBorrowmoney exaBorrowmoney)
    {
        return toAjax(exaBorrowmoneyService.updateExaBorrowmoney(exaBorrowmoney));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:borrowmoney:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exaBorrowmoneyService.deleteExaBorrowmoneyByIds(ids));
    }
}
